package com.itheima.reggie.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.itheima.reggie.domain.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;
import java.util.Map;

@Mapper
public interface OrderDao extends BaseMapper<Orders> {

    @Select("SELECT name,SUM(od.number) number,od.amount amount" +
            " FROM orders o,order_detail od" +
            " WHERE o.id = od.order_id " +
            " AND o.order_time BETWEEN #{startTime} AND #{endTime} AND  dish_id IS NOT NULL" +
            " GROUP BY name ORDER BY number DESC LIMIT 10;")
    List<Map> reportCount(Date startTime, Date endTime);
}
